Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add email queue to handle email sending failures #1587

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mahendraHegde
Copy link
Contributor

@mahendraHegde mahendraHegde commented Jan 18, 2025

  • ability to enqueue failed emails and retry them later
    • why not push all emails to queue? because, then we need need to increase pg-boss polling frequency(more queries to postgress every minute), if not users will always have to wait for X minute to receive any email, some tokens/OTPs will have lifetime of X minutes
  • We dont await triggerEmail call inside sendEmail anymore, so that any user facing actions can finish without waiting for email send to complete, this is actually a tradeoff, because if email sending fails(1st attempt + 5 retries using queues) user never will be warned, but the case is very unlikely and the benefit supersedes the tradeoff.


export const sendEmail = (payload: EmailPayloadType) => {
// attempt to send email, push to the queue if it fails
triggerEmail(payload).catch((err) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont await, so users dont have to wait for long running email api calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant